home *** CD-ROM | disk | FTP | other *** search
-
- section x,code
-
- opt w-
-
- ; IFF-to-ANSI V0.1 Sourcecode (Buddha's MasterSeka rules)
- ; active font should be TOPAZ 80 (no 60 char display, please...)
- ; this one really NEEDS the genious 'Req.library' !
- ;
- ; programmed by Carnivore/BeerMacht
- ; on 9-Nov-1990
- ;
- ; I declare executable and sourcecode as 100% FreeWare
- ;
- ; Notes:TOPLINE below 12 changes to borderless window
- ; take care of the HEIGHT value to prevent text beeing written
- ; below the bottomline (NTSC?) if no borderless window is set
- ;
-
- CloseLibrary = -414
- OldOpenLibrary = -408
-
- Close = -36
- Open = -30
- Output = -60
- Read = -42
- Write = -48
-
- FileRequester = -$54
- GetLong = -$b4
-
- dsize = 130
- fchars = 30
- wildlen = 30
-
- maxiffsize = 20000 ;iff bufsize
-
- run: move.l 4.w,a6
- lea reqname(pc),a1
- jsr OldOpenLibrary(a6)
- move.l d0,reqbase
- beq.L noreq ;the errormessages down here are
- ;quite poor, but who cares...
-
- move.l d0,a0
- move.l $26(a0),dosbase
- move.l dosbase(pc),a6
- jsr Output(a6)
- move.l d0,d1
- beq.s noclihd
- lea clitxt(pc),a2
- move.l a2,d2
- move.l #clilen,d3
- jsr Write(a6)
-
- noclihd:move.l reqbase(pc),a6
- lea fileload(pc),a0
- jsr FileRequester(a6)
- tst.l d0
- beq.L nofile
-
- move.l dosbase(pc),a6
- lea frpath(pc),a0
- move.l a0,d1
- move.l #1005,d2
- jsr Open(a6)
- move.l d0,srchd
- beq.L notfnd
- move.l d0,d1
- move.l #iffdata,d2
- move.l #maxiffsize,d3
- jsr Read(a6)
-
- move.l srchd(pc),d1
- jsr Close(a6)
-
- lea iffdata,a0
- cmp.l #"FORM",(a0)
- bne.L noiff
- bsr.L iffsize
-
- cmp.b #1,d0 ;#planes
- bne.L toomany
- move.w d1,bytes
- cmp.w #40,d1
- bhi.L toowide
- moveq #40,d0
- sub.w d1,d0
- lsl.w #3,d0 ;center ansipic
- move.w d0,leftoff
-
- move.w d2,hgtreq+4+2 ;default
-
- lea iffdata,a0
- lea bpltab,a1
- lea coltab,a2
- clr.l d0
- bsr.l iffunpack
-
- move.l reqbase(pc),a6
- lea topreq(pc),a0
- jsr GetLong(a6)
- tst.l d0
- beq.L notop
- move.w topreq+16+2(pc),d0
- move.b d0,linenum
- sub.w d0,hgtreq+12+2 ;max
- move.w hgtreq+12+2(pc),d0 ;max
- cmp.w hgtreq+4+2(pc),d0 ;default
- bhi.s sizeok
- move.w d0,hgtreq+4+2 ;default
-
- sizeok: lea hgtreq(pc),a0
- jsr GetLong(a6)
- tst.l d0
- beq.s nohgt
- move.w hgtreq+16+2(pc),lines
-
- lea csrreq(pc),a0
- jsr GetLong(a6)
- tst.l d0
- beq.s nocsr
- move.w csrreq+16+2(pc),csrrow
-
- bsr.L doansi
- move.l a0,d7 ;a0:length
- ;;;
-
- lea filesave(pc),a0
- jsr FileRequester(a6)
- tst.l d0
- beq.s nosav
-
- move.l dosbase(pc),a6
- lea frpath(pc),a0
- move.l a0,d1
- move.l #1006,d2
- jsr Open(a6)
- move.l d0,desthd
- beq.s notwr
- move.l d0,d1
- move.l #ansibuf,d2
- move.l d7,d3 ;length
- jsr Write(a6)
-
- move.l desthd(pc),d1
- jsr Close(a6)
-
- moveq #-1,d0
- lea $dff006,a0
- raul: move.w (a0),$180-6(a0) ;blink if no error (??)
- dbf d0,raul
-
- notwr:
- nosav:
-
- nocsr:
- nohgt:
- notop:
-
- toowide:
- toomany:
-
- noiff:
-
- notfnd:
- nofile:
-
- allesok:move.l 4.w,a6
- move.l reqbase(pc),a1
- jsr CloseLibrary(a6)
- noreq: clr.l d0
- rts
-
- doansi: sf inv
- lea ansibuf,a0
- lea bpl1,a1
-
- move.l #$9b302070,(a0)+ ;cursor off
-
- move.w #$9b30,(a0)+
- move.w #$6d20,(a0)+ ;reset txtmode
-
- move.w leftoff(pc),d1 ;borderless if pic is wide
- cmp.w #16,d1
- bls.s nobord
-
- cmp.b #12-1,linenum ;borderless if topline <12
- bhi.s topok
-
- nobord: move.l #$9b333274,(a0)+ ;32 row
-
- move.l #$9b383175,(a0)+ ;set linelength 81 if full width
-
- move.b #$9b,(a0)+ ;clr window top if topline < 12
- move.b #"0",(a0)+
- move.b #$79,(a0)+ ;pix top
- move.b #$9b,(a0)+ ;clr window top if topline < 12
- move.b #"0",(a0)+
- move.b #$78,(a0)+ ;pix left
-
- topok: move.b #12,(a0)+ ;clrscr again (for borderless)
-
- move.b #$9b,(a0)+
- bsr.L dodez
- move.b #$78,(a0)+ ;pix left
-
- move.w lines(pc),d4
- linelp: bsr.L doline
- move.b #13,(a0)+
-
- subq.w #1,d4
- bmi.L endpic
-
- move.l a1,a3
- move.w bytes(pc),bytenum
-
- move.w bytes(pc),d0
- move.l a1,a4
- sub.w d0,a4 ;previous line
- subq.w #1,d0
- move.l a1,a2
- moveq #-1,d1
- cntspc: addq.l #1,d1
- tst.b (a4)+ ;dots in previous line?
- bne.s clrprev
- tst.b (a2)+
- dbne d0,cntspc
- tst.w d0
- bmi.s clrrest
- clrprev:tst.l d1
- beq.s nospc
- cmp.b #1,d1 ;8dots=2spc <3chrs
- beq.s nospc
- add.w d1,a3
- sub.w d1,bytenum
- add.w d1,d1
-
- move.b #$9b,(a0)+
- bsr.L dodez
- move.b #$43,(a0)+ ;cursor n right
- nospc:
-
- bitline:subq.w #1,bytenum
- bmi.s endline ;all bytes converted
- clr.w d2
- move.b (a3),d2
- lsr.b #4,d2 ;left 4 bits
- bsr.L donibb
- move.b (a3)+,d2
- and.w #$000f,d2
- bsr.L donibb
-
- move.w bytenum(pc),d0
- subq.w #1,d0
- bmi.s bitline
- move.l a3,a2 ;check rest of line for bits
- move.l a3,a4
- sub.w bytes(pc),a4 ;previous line
- sf d2
- chkline:tst.b (a4)+
- beq.s isok
- st d2 ;dots in previous line!
- isok: tst.b (a2)+
- dbne d0,chkline
- tst.w d0
- bpl.s bitline
- tst.b d2
- beq.s isclr
- clrrest:move.b #$9b,(a0)+
- move.b #$4b,(a0)+ ;clr rest of line
- isclr:
-
- endline:add.w bytes(pc),a1
- bra.L linelp
-
- endpic: move.b #$9b,(a0)+ ;Yoe! I'm too lasy to do it better
- move.b #$4d,(a0)+ ;clrline
- move.b #$9b,(a0)+
- move.b #$74,(a0)+ ;line num reset
- move.b #$9b,(a0)+
- move.b #$75,(a0)+ ;line length reset
- move.b #$9b,(a0)+
- move.b #$78,(a0)+ ;pix left reset
- move.b #$9b,(a0)+
- move.b #$79,(a0)+ ;pix top reset
- move.b #$9b,(a0)+ ;normal video
- move.b #"0",(a0)+
- move.b #"m",(a0)+
- move.b #$9b,(a0)+ ;cursor row
- move.w csrrow(pc),d1
- bsr.s dodez
- move.b #$48,(a0)+
- move.b #$9b,(a0)+ ;cursor on
- move.b #" ",(a0)+
- move.b #$70,(a0)+
- lea ansibuf,a1
- sub.l a1,a0 ;length of ansitxt
- rts
-
- doline: move.b #$9b,(a0)+ ;$9b,nnn,$79
- clr.w d1
- move.b linenum(pc),d1
- bsr.s dodez
- move.b #$79,(a0)+
- addq.b #1,linenum
- rts
-
- dodez: sf d0
- ext.l d1
- divu #100,d1
- tst.w d1
- beq.s no100
- st d0
- add.b #"0",d1
- move.b d1,(a0)+
- clr.w d1
- no100: swap d1
- divu #10,d1
- tst.b d0
- bne.s is10
- tst.w d1
- beq.s no10
- is10: add.b #"0",d1
- move.b d1,(a0)+
- no10: swap d1
- add.b #"0",d1
- move.b d1,(a0)+
- rts
-
- donibb: lsl.b #3,d2 ;*8
- lea tab(pc),a2 ;chartab normal
- tst.b inv
- beq.s notinv
- lea tab2(pc),a2 ;chartab inverse
- notinv: cmp.b #"7",1(a2,d2.w)
- bne.s nochg
- st inv
- nochg: cmp.b #"0",1(a2,d2.w)
- bne.s nochg2
- sf inv
- nochg2:
- seqloop:move.b (a2,d2.w),d0 ;copy char/ansisequence
- beq.s endseq
- move.b d0,(a0)+
- addq.w #1,d2
- bra.s seqloop
- endseq: rts
-
- ; Name: iffsize (used with Tristar's kind permission?)
- ; In: a0.l=Zeiger auf iffpic
- ; Out: d0.w=Anzahl Planes
- ; d1.w=Bytes pro Zeile
- ; d2.w=Anzahl Zeilen
-
- iffsize: move.l a0,-(sp)
- add.w #12,a0
- iffsize0: cmp.l #'BMHD',(a0)
- beq.s iffsize1
- move.l 4(a0),d0
- lea 8(a0,d0.l),a0
- bra.s iffsize0
- iffsize1: move.w 8(a0),d1
- move.w d1,d2
- lsr.w #4,d1
- and.w #15,d2
- beq.s iffsize2
- addq.w #1,d1
- iffsize2: add.w d1,d1
- move.w 10(a0),d2
- moveq #0,d0
- move.b 16(a0),d0
- move.l (sp)+,a0
- rts
-
- ; iffunpack (used with Tristar's kind permission?)
- ; In: a0.l=Zeiger auf iffpic
- ; a1.l=Zeiger auf Tabelle mit Zeigern auf die einzelnen
- ; Planepuffer (wird nicht zerstoert)
- ; a2.l=Zeiger auf Puffer fuer Farbwerte
- ; d0.w=Offset, der (intern) auf a2 addiert wird, nachdem ein
- ; Farbwert in den Puffer geschrieben wurde (normal=2,
- ; fuer Copperliste=4)
- ; Out: -
-
- iffunpack: movem.l d0-d7/a0-a6,-(sp)
- add.w #12,a0
- iffunpack0: cmp.l #'BMHD',(a0)
- beq.s iffunpack1
- move.l 4(a0),d1
- lea 8(a0,d1.l),a0
- bra.s iffunpack0
- iffunpack1: move.l a0,a3
- iffunpack2: cmp.l #'CMAP',(a0)
- beq.s iffunpack3
- move.l 4(a0),d1
- lea 8(a0,d1.l),a0
- bra.s iffunpack2
- iffunpack3: moveq #1,d1
- move.b 16(a3),d2
- lsl.w d2,d1
- lea 8(a0),a4
- bra.s iffunpack5
- iffunpack4: move.b (a4)+,d2
- lsl.w #4,d2
- and.w #$0f00,d2
- move.b (a4)+,d2
- and.w #$0ff0,d2
- move.b (a4)+,d3
- lsr.b #4,d3
- and.w #$000f,d3
- or.w d3,d2
- move.w d2,(a2)
- add.w d0,a2
- iffunpack5: dbf d1,iffunpack4
- iffunpack6: cmp.l #'BODY',(a0)
- beq.s iffunpack7
- move.l 4(a0),d0
- lea 8(a0,d0.l),a0
- bra.s iffunpack6
- iffunpack7: moveq #0,d7
- move.b 16(a3),d7
- subq.w #1,d7
- moveq #0,d0
- move.w d7,d1
- iffunpack8: move.l 0(a1,d0.w),-(sp)
- addq.w #4,d0
- dbf d1,iffunpack8
- move.w d0,-(sp)
- move.w 8(a3),d6
- move.w d6,d2
- lsr.w #4,d6
- and.w #15,d2
- beq.s iffunpack9
- addq.w #1,d6
- iffunpack9: add.w d6,d6
- move.l 4(a0),d0
- lea 8(a0,d0.l),a2
- addq.l #8,a0
- iffunpacka: cmp.l a2,a0
- bge.s iffunpackj
- moveq #0,d3
- move.w d7,d2
- iffunpackb: move.l 0(a1,d3.l),a4
- bsr.s iffunpackc
- move.l a4,0(a1,d3.l)
- addq.l #4,d3
- dbra d2,iffunpackb
- bra.s iffunpacka
- iffunpackc: lea 0(a4,d6.w),a5
- iffunpackd: cmp.l a5,a4
- bge.s iffunpackl
- tst.b 18(a3)
- bne.s iffunpacke
- move.w d6,d0
- bra.s iffunpackg
- iffunpacke: move.b (a0)+,d0
- ext.w d0
- bmi.s iffunpackh
- iffunpackf: move.b (a0)+,(a4)+
- iffunpackg: dbf d0,iffunpackf
- bra.s iffunpackd
- iffunpackh: neg.w d0
- move.b (a0)+,d1
- iffunpacki: move.b d1,(a4)+
- dbf d0,iffunpacki
- bra.s iffunpackd
- iffunpackj: move.w (sp)+,d0
- move.w d7,d1
- iffunpackk: subq.w #4,d0
- move.l (sp)+,0(a1,d0.w)
- dbf d1,iffunpackk
- movem.l (sp)+,d0-d7/a0-a6
- iffunpackl: rts
- ; hang that bastard pope...
- fileload:dc.w 0 ;version
- dc.l title
- dc.l 0
- dc.l 0
- dc.l frpath
- dc.l 0
- dc.w 0
- dc.w 14 ;numlines
- dc.w 30 ;numcolumns
- dc.w 12 ;devcolumns
- dc.l $10+$40+$1000 ;hideinfo,absxy,save($1000=load)
- dc.w 3 ;dircolor
- dc.w 0 ;filecolor
- dc.w 3 ;devcolor
- dc.w 0 ;fontnamecolor
- dc.w 0 ;fontsizecolor
- dc.w 0 ;detailcolor
- dc.w 0 ;blockcolor
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dcb.b 36,0
- dcb.l 3,0 ;datestamp
- dc.w 3 ;wdleft
- dc.w 11 ;wdtop
- dc.w 0
- dc.w 0
- dc.l 0
- dcb.b wildlen+2,0
- dcb.b wildlen+2,0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.l 0
- dc.l 0
- dc.l 0
- dcb.b dsize+2,0
- dc.l 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- ; slaves of death, addicted to gore...
- filesave:dc.w 0 ;version
- dc.l title2
- dc.l 0
- dc.l 0
- dc.l frpath
- dc.l 0
- dc.w 0
- dc.w 14 ;numlines
- dc.w 30 ;numcolumns
- dc.w 12 ;devcolumns
- dc.l $10+$40+$800 ;hideinfo,absxy,save($1000=load)
- dc.w 3 ;dircolor
- dc.w 0 ;filecolor
- dc.w 3 ;devcolor
- dc.w 0 ;fontnamecolor
- dc.w 0 ;fontsizecolor
- dc.w 0 ;detailcolor
- dc.w 0 ;blockcolor
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dcb.b 36,0
- dcb.l 3,0 ;datestamp
- dc.w 3 ;wdleft
- dc.w 11 ;wdtop
- dc.w 0
- dc.w 0
- dc.l 0
- dcb.b wildlen+2,0
- dcb.b wildlen+2,0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.l 0
- dc.l 0
- dc.l 0
- dcb.b dsize+2,0
- dc.l 0
- dc.w 0
- dc.w 0
- dc.w 0
- dc.w 0
- ; with my chainsaw in hand your death I command...
- topreq: dc.l topname
- dc.l 12 ;default
- dc.l 0 ;min
- dc.l 256 ;max
- dc.l 0 ;result
- dc.l 0
- dc.w 0
- dc.l 0
- dc.l 0
- hgtreq: dc.l hgtname
- dc.l 0 ;default
- dc.l 0 ;min
- dc.l 256 ;max
- dc.l 0 ;result
- dc.l 0
- dc.w 0
- dc.l 0
- dc.l 0
- csrreq: dc.l csrname
- dc.l 20 ;default
- dc.l 1 ;min
- dc.l 32 ;max
- dc.l 0 ;result
- dc.l 0
- dc.w 0
- dc.l 0
- dc.l 0
-
- bpltab: dc.l bpl1
- coltab: dc.w 0
- reqbase:dc.l 0
- bytes: dc.w 0 ;# of bytes/gfxline
- lines: dc.w 0 ;# of gfxlines
- leftoff:dc.w 0 ;# pixel to left border
- bytenum:dc.w 0 ;gfxbytecounter
- csrrow: dc.w 0 ;row to put cursor at end of pic
- file: dc.l 0
- dosbase:dc.l 0
- srchd: dc.l 0 ;filehandle source
- desthd: dc.l 0 ;filehandle dest
-
- title: dc.b "Select IFF-source (LORES, 1 bitplane) ",0
- title2: dc.b "Select the filename of the ANSI-text ",0
- frpath: dcb.b dsize+fchars+2,0
- hgtname:dc.b "Height of ANSIpic ",0
- topname:dc.b "Offset to TOPLINE ",0
- csrname:dc.b "Put cursor in ROW ",0
- reqname:dc.b "req.library",0 ;Yo! the only one, you NEED it.
- clitxt: dc.b 12,$9b,"0;31;42m"
- dc.b $9b,"49",$43
- dc.b " IFF-to-ANSI V0.1 9-Nov-90 ",10
- dc.b $9b,"49",$43
- dc.b " a tool completely FreeWare ",10
- dc.b $9b,"49",$43
- dc.b "to convert a LORES-IFF-BRUSH",10
- dc.b $9b,"49",$43
- dc.b "into an optimised ANSI-text.",10
- dc.b $9b,"49",$43
- dc.b "Done by Carnivore/BeerMacht.",10
- dc.b $9b,"49",$43
- dc.b " Stoned greetings go to all ",10
- dc.b $9b,"49",$43
- dc.b " lovers of Diebels Alt and ",10
- dc.b $9b,"49",$43
- dc.b " all those nice sick movies ",10
- dc.b $9b,"49",$43
- dc.b "(ILSA and Necromantic rule).",10
- dc.b $9b,"0m"
- clilen=*-clitxt
- linenum:dc.b 0 ;gfxlinecounter
- inv: dc.b 0 ;inverseflag: 0:normal,-1:inverse
-
- tab: dc.b " ",0,0,0,0,0,0,0 ;chartab for normal display
- dc.b "/",0,0,0,0,0,0,0 ;TOPAZ 80 !!!
- dc.b "(",0,0,0,0,0,0,0
- dc.b $9b,"7m","L",0,0,0,0
- dc.b ")",0,0,0,0,0,0,0
- dc.b "ä",0,0,0,0,0,0,0
- dc.b "0",0,0,0,0,0,0,0
- dc.b $9b,"7m","\",0,0,0,0
- dc.b "\",0,0,0,0,0,0,0
- dc.b "V",0,0,0,0,0,0,0
- dc.b $7f,0,0,0,0,0,0,0
- dc.b $9b,"7m",")",0,0,0,0
- dc.b "L",0,0,0,0,0,0,0
- dc.b $9b,"7m","(",0,0,0,0
- dc.b "B",0,0,0,0,0,0,0
- dc.b $9b,"7m"," ",0,0,0,0
- ;don't deny the necrophile!
- tab2: dc.b $9b,"0m"," ",0,0,0,0 ;chartab for inverse display
- dc.b "B",0,0,0,0,0,0,0
- dc.b $9b,"0m","(",0,0,0,0
- dc.b "L",0,0,0,0,0,0,0
- dc.b $9b,"0m",")",0,0,0,0
- dc.b $7f,0,0,0,0,0,0,0
- dc.b "V",0,0,0,0,0,0,0
- dc.b "\",0,0,0,0,0,0,0
- dc.b $9b,"0m","\",0,0,0,0
- dc.b "0",0,0,0,0,0,0,0
- dc.b "ä",0,0,0,0,0,0,0
- dc.b ")",0,0,0,0,0,0,0
- dc.b $9b,"0m","L",0,0,0,0
- dc.b "(",0,0,0,0,0,0,0
- dc.b "/",0,0,0,0,0,0,0
- dc.b " ",0,0,0,0,0,0,0
-
- dc.b "another sick BeerMacht production"
- data ;3 MB are mine, so why bother with AllocMem?
- iffdata: dcb.b maxiffsize,0 ;lores
-
- bplsecurity:
- dcb.b 40,0 ;line -1
- bpl1: dcb.b 16000,0 ;bitplanedata
-
- ansibuf:dcb.b $10000,0 ;ansi/destination
- ;
- ;Yo, this is the end...
-